local socket = require"socket"
local ffi = require"ffi"

local size = 1000

local t = ffi.new("int[?]",size)



local function carray(size)
    local self = {
    }
    self.byte_data = love.data.newByteData(size * 4)
    self.data_view = love.data.newDataView(self.byte_data,0,4)
    self.bd_ptr = ffi.cast("uint8_t *",self.byte_data:getFFIPointer())
    self.ptr = ffi.cast("int *",self.data_view:getFFIPointer())
    return self;
end

local arr = carray(5)

for i = 0,4 do
    arr.ptr[i] = i
end

for i = 0,4 do
    print(arr.ptr[i])
end


--byte -> kb -> mb

-- local thread = love.thread.newThread([[
--     while true do
--         local t = love.thread.getChannel("t"):pop()
--         if t ~= nil then
--             print("????")
--             break;
--         end
--     end

-- ]])

-- thread:start()

-- function love.load()
--     local time = socket.gettime()
--     love.thread.getChannel("t"):push(t)
--     print((socket.gettime() - time) * 1000)
-- end

-- function love.threaderror(...)
--     print(...)
-- end